home *** CD-ROM | disk | FTP | other *** search
- Path: news.uh.edu!cosc19z5
- From: cosc19z5@Bayou.UH.EDU (Spasmo)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character
- Followup-To: comp.lang.c,comp.unix.programmer
- Date: 3 Apr 1996 08:38:21 GMT
- Organization: University of Houston
- Distribution: world
- Message-ID: <4jtddt$eu7@masala.cc.uh.edu>
- References: <31616F63.481D@lava.weeg.uiowa.edu>
- NNTP-Posting-Host: bayou.uh.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Artur Wojdat (awojdat@lava.weeg.uiowa.edu) wrote:
- : Hello everybody,
- : Is there a function or some sort of way that I could remove '\n'
- : charecter form the end of the string. I'm reading from two files, want to
- : form one line of text and then have it printed out to stdout. I use fgets to
- : read from the file and I noticed that it appends newline char at the end.
- : It is important that two lines of text, one from each file, will be
- : combined into one and I can't do it because the first string has '\n' added
- : to it. I'm picky becauuse the output will be used to feed another program and
- : I'm affraid that not properly formatted input may corrupt the process.
- : Any suggestions will be greatly appreciated .. Thanks, Art ...
-
- Dunno if there are any functions available, but what I always do
- is just overwrite the '\n' with a '\0', which does the job nicely.
-
- For example, let's say that the string that holds the data is called
- buf. To get rid of the '\n' you'd merely do the following:
-
- buf[strlen(buf) - 1] = '\0';
-
- And that takes care of that.
-
- Hope this helped.
-
- --
-
- .A. G-Force! 1 AM Houston Time
- AAAAA On the Cartoon Network!
- AAY:YAA
- A':::`A This informative message was
- ::::::: brought to you by Spasmo.
- ::( )::
- :::::::
- :::::::
- :::::::
- :::::::
- .A. .do:::::::::::bo. .A.
- AAA .:::::::::::::::::::::. AAA
- d:::::::::::::::::::::::::::::::::::::::::::b
- Y:::::::::::::::::::::::::::::::::::::::::::Y
- `YjY `:::::::|::|::|:::::::' YjY'
- `::|::|::|::'
- |
-